﻿using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Volo.Abp;

namespace Wiz.Minio.EventData;

public class EventDataHostedService : IHostedService
{
    private readonly IAbpApplicationWithExternalServiceProvider _abpApplication;
    private readonly TestService _testService;

    public EventDataHostedService(TestService testService, IAbpApplicationWithExternalServiceProvider abpApplication)
    {
        _testService = testService;
        _abpApplication = abpApplication;
    }
    
  
    /// <summary>
    /// 异步启动服务任务。
    /// </summary>
    /// <param name="cancellationToken">取消令牌。</param>
    /// <returns>表示异步操作的任务。</returns>  
    public async Task StartAsync(CancellationToken cancellationToken)
    {
        await _testService.StartAsync(cancellationToken);
    }

    public async Task StopAsync(CancellationToken cancellationToken)
    {
        await _abpApplication.ShutdownAsync();
    }
}
